<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ include file="static/imgHost.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>支付</title>
    
    <script src="<%=basePath%>js/fontSize.js"></script>
    <script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
    
    <link rel="stylesheet" href="<%=basePath%>css/style.css"/>
    <link rel="stylesheet" href="<%=basePath%>css/style2.css"/>
    <style>
      body{
        background: #efeff4;
      }
    </style>
</head>

<body>
  <div class="payment-head">
    <div class="payment-img">
		<c:choose>
			<c:when test="${empty memberModel.avatar}"><img src="<%=basePath%>images/img51.png"></c:when>
			<c:otherwise><img src="${memberModel.avatar}" width="100%"></c:otherwise>
		</c:choose>
    </div>
    <h2>${memberModel.nick_name}</h2>
  </div>
  <div class="payment-input">
  <span>现金(元)</span>
  <input id="money" type="number" min="0" placeholder="请输入转账金额">
  </div>
  <div class="payment-info clearfix">
    <p class="payment-info-pf fl">您的账户余额：<span style="color:#000">¥<em id="coin_num">${memberModel.coin_num}</em></span></p>
    <!-- <p  class="payment-info-pl fr">金币兑换比例：1金币=1元</p> -->
  </div>
  <button class="evaluate-release" id="next_step">确定</button>
  <script src="<%=basePath%>js/style.js"></script>
  <script type="text/javascript">
  	$(function(){
  		$("#money").myvalidate({
  	        filter_type: "positiveNumber"
  	    });
  		$("#next_step").click(function() {
  			var money = $("#money").val();
  			var coin_num = parseFloat($("#coin_num").text())
  			if (null == money || money == "" || money == 0) {
  				alert("请输入转账金额");
  				$("#money").focus();
  				return;
  			} else if (money > coin_num) {
  				alert("您的余额不足，不能进行支付操作");
  				$("#money").focus();
  				return;
  			}
  			window.location.href = "<%=basePath%>member/u/scan_pay/"+money;
  		});
  	});
  </script>
  <script type="text/javascript">
  (function ($) {
	    var my_validate_plug_name = "myvalidate";
	    function MyJqValidate(element, options){
	        this.init(element, options);
	    }
	    MyJqValidate.prototype = {
	        init: function (element, options) {
	            var allowFilter = ["positiveNumber"];
	            var defaults = {filter_type: "positiveNumber", enterCallback: function (obj){},
	                valCallback: function (val){}};
	            this.element = element;
	            this.settings = $.extend( {}, defaults, options );
	            if($.inArray( this.settings.filter_type, allowFilter) == -1) {
	                return;
	            }
	            this[this.settings.filter_type].call(this);
	        },
	        positiveNumber: function (){
	            var _this = this;
	            /* 大于0的正则匹配    匹配：0.1   1.  3.0  	.1 */
	            this.element.keyup(function (e){
	                var code = e.keyCode || e.which;
	                var txt = $(this).val();
	                var reg = /^(0*\.?[1-9]\d*|[1-9]+(\d*\.\d*)?)$/;
	                if(reg.test(txt)){
	                    callback.call(_this, e);
	                    return;
	                }
	                var numb = txt.match(/\d|\./g);
	                if(numb == null) {
	                    $(this).val("");
	                    callback.call(_this, e);
	                    return;
	                }
	                numb = numb.join("");
	                var str = "";
	                var f = true;
	                for(var i=0; i<numb.length; i++){
	                    var s = numb[i];
	                    if (s=="."){
	                        if (f) {
	                            str += s;
	                            f = false;
	                        }
	                    } else {
	                        str += s;
	                    }
	                }
	                $(this).val(str);
	                callback.call(_this, e);
	            });
	            function callback(e){
	                this.value = $.trim(this.element.val());
	                var v = parseFloat(this.value);
	                this.format_value = isNaN(v) ? 0 : v;
	                this.settings.valCallback(this.format_value);
	                var code = e.keyCode || e.which;
	                if(code == 13) { //Enter keycode
	                    this.settings.enterCallback(this.element);
	                }
	            }
	        }
	    }

	    $.fn[my_validate_plug_name] = function(options){
	        var elt;
	        if ( options instanceof Object || !this.data( "plugin_" + my_validate_plug_name ) ) {
	            elt = new MyJqValidate( this, options );
	            this.data('plugin_' + my_validate_plug_name, elt);
	        } else {
	            elt = this.data( "plugin_" + my_dialog_plug_name );
	        }
	        if (typeof(options) == "string" && options.length>0){
	            eval("elt."+options+"(this)");
	        }
	        return this;
	    }
	}( jQuery ));
  </script>
</body>
</html>